<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录界面</title>
</head>
<link rel="stylesheet" href="css/login.css">
<link rel="stylesheet" href="css/whole.css">
<body>
    <center>
        <div id="login">
            <h1
                    style="font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; font-size: 55px; color: aliceblue;">
                welcome
            </h1>
            <form id="loginForm">

                <ul>
                    <li class="users">
                        <input type="text" id="usersText" name="usersText" placeholder="注册账号/注册用户名"
                            style="font-size: 20px;color: papayawhip;" />
                    </li>
                    <li class="pwd">
                        <input type="password" id="pwdText" name="pwdText"  placeholder="注册密码/注册邮箱"
                            style="font-size: 20px;color: papayawhip;" />
                    </li>
                    <li class="forget">
                        <a href="">忘记密码</a>
                    </li>
                </ul>
                <button id="go" type="button" onclick="jump()">
                    登 录
                </button>
                <p class="or">
                    Or
                </p>
                <p>
                    <button id="registered"  type="button" onclick="register()">
                        注 册
                    </button>
                </p>
            </div>

            </form>
    </center>
</body>
<script src="js/jquery-3.6.0.min.js"></script>
<script>

    //跳转注册
    function register(){
        window.location.href='/register';
    };


    function jump() {
        //button按钮能用
        //验证能用

        let usersText = $('#usersText').val();
        console.log(usersText);
        let pwdText = $('#pwdText').val();
        if(usersText.length > 0 && pwdText.length > 0){
            $.ajax({
                    url: "/loginDone",
                    type: "POST",
                    data: $('#loginForm').serialize(),
                    dataType: "json",
                    success: function (res) {
                        console.log(res);
                        if(res.code===200){
                            window.location.href="/talksay";
                        }else{
                            alert('aaa')
                        }
                    }
                })
        }else{
           alert('bbb')
        }
    };

        


</script>

</html>